//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.example.service;

import cn.hutool.core.date.DateUtil;
import com.example.entity.Recruitment;
import com.example.mapper.RecruitmentMapper;
import com.example.mapper.RecruitmentapplicationMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Iterator;
import java.util.List;

@Service
public class RecruitmentService {
    @Resource
    private RecruitmentMapper recruitmentMapper;

    @Resource
    private RecruitmentapplicationMapper recruitmentapplicationMapper;

    public RecruitmentService() {
    }

    public void add(Recruitment recruitment) { //管理员不需要注册只需要新增，只有管理员才能增加管理员
        this.recruitmentMapper.insert(recruitment);
    }

    public void updateById(Recruitment recruitment) {
        this.recruitmentMapper.updateById(recruitment);
    }

    @Transactional
    public void deleteById(Integer id) {
        //删除招募数据
        recruitmentMapper.deleteById(id);
        //删除学生招募申请数据
        recruitmentapplicationMapper.deleteByRecruitmentId(id);
    }

    public void deleteBatch(List<Integer> ids) {
        Iterator var2 = ids.iterator();

        while(var2.hasNext()) {
            Integer id = (Integer)var2.next();
            this.deleteById(id);
        }

    }

    public Recruitment selectById(Integer id) {
        return this.recruitmentMapper.selectById(id);
    }

    public List<Recruitment> selectAll(Integer clubId) {
        return this.recruitmentMapper.selectAll(clubId);
    }

    public List<Recruitment> selectList(Recruitment recruitment) {
        System.out.println(recruitment);
        return null;
    }

    public List<Recruitment> selectByClubs(List<Integer> clubIds,String title) {

        return recruitmentMapper.selectByClubs(clubIds,title);
    }

//    public PageInfo<Recruitment> selectPage(Recruitment recruitment, Integer pageNum, Integer pageSize, Integer studentId) {
//        PageHelper.startPage(pageNum, pageSize);
//        List<Recruitment> list = this.recruitmentMapper.selectAll(recruitment, studentId);
//        return PageInfo.of(list);
//    }
    
}
